﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GalaSoft.MvvmLight;
using System.Collections.ObjectModel;
using System.IO;

namespace ExcelMergeDocs.WinClient.ViewModel {
    public class DocViewModel : SelectableViewModel {
        public DocViewModel() {
            this.PropertyChanged += DocViewModel_PropertyChanged;
        }

        void DocViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
            if (e.PropertyName == IsSelectedPropertyName) {
                foreach (var item in this.Worksheets) {
                    item.IsSelected = IsSelected;
                }
            }
        }

        public override void Cleanup() {
            this.PropertyChanged -= DocViewModel_PropertyChanged;
        }

        #region Filepath
        private string _filepath;
        public const string FilepathPropertyName = "Filepath";

        public string Filepath {
            get { return _filepath; }
            set {
                if (_filepath != value) {
                    RaisePropertyChanged(FilepathPropertyName, _filepath, value, true);
                    _filepath = value;
                }
            }
        }
        #endregion end

        #region Worksheets
        private ObservableCollection<WSViewModel> _worksheets;

        public ObservableCollection<WSViewModel> Worksheets {
            get {
                return _worksheets ?? (_worksheets = new ObservableCollection<WSViewModel>());
            }
        }
        #endregion



    }
}
